/*********************************************************
*  OCUnity Project - A Test C Framework for testing OpenCPU
*  Copyright (c) 2021 China Mobile IOT.
*  created by sushundi 2021-09-24
********************************************************/

#ifndef OCTEST_INTERNALS_H
#define OCTEST_INTERNALS_H

/*user must define UnityPrintf here or implement your own UnityPrintf function*/
#include "cm_demo_uart.h"
#define OCTestPrintf cm_demo_printf

#define OCTEST_DISPLAY_RANGE_INT  (0x10)
#define OCTEST_DISPLAY_RANGE_UINT (0x20)
#define OCTEST_DISPLAY_RANGE_HEX  (0x40)
#define OCTEST_DISPLAY_RANGE_CHAR (0x80)

typedef signed int OCTEST_INT32;
typedef unsigned int OCTEST_UINT32;
typedef enum
{
    OCTEST_DISPLAY_STYLE_INT      = 4 + OCTEST_DISPLAY_RANGE_INT,
    OCTEST_DISPLAY_STYLE_INT8     = 1 + OCTEST_DISPLAY_RANGE_INT,
    OCTEST_DISPLAY_STYLE_INT16    = 2 + OCTEST_DISPLAY_RANGE_INT,
    OCTEST_DISPLAY_STYLE_INT32    = 4 + OCTEST_DISPLAY_RANGE_INT,

    OCTEST_DISPLAY_STYLE_UINT     = 4 + OCTEST_DISPLAY_RANGE_UINT,
    OCTEST_DISPLAY_STYLE_UINT8    = 1 + OCTEST_DISPLAY_RANGE_UINT,
    OCTEST_DISPLAY_STYLE_UINT16   = 2 + OCTEST_DISPLAY_RANGE_UINT,
    OCTEST_DISPLAY_STYLE_UINT32   = 4 + OCTEST_DISPLAY_RANGE_UINT,

    OCTEST_DISPLAY_STYLE_HEX8     = 1 + OCTEST_DISPLAY_RANGE_HEX,
    OCTEST_DISPLAY_STYLE_HEX16    = 2 + OCTEST_DISPLAY_RANGE_HEX,
    OCTEST_DISPLAY_STYLE_HEX32    = 4 + OCTEST_DISPLAY_RANGE_HEX,

    OCTEST_DISPLAY_STYLE_CHAR     = 1 + OCTEST_DISPLAY_RANGE_CHAR + OCTEST_DISPLAY_RANGE_INT,
    
    OCTEST_DISPLAY_STYLE_BOOL     = 2 + OCTEST_DISPLAY_RANGE_CHAR + OCTEST_DISPLAY_RANGE_INT,
    OCTEST_DISPLAY_STYLE_NULL     = 3 + OCTEST_DISPLAY_RANGE_CHAR + OCTEST_DISPLAY_RANGE_INT,

    OCTEST_DISPLAY_STYLE_UNKNOWN
} OCTEST_DISPLAY_STYLE_T;

typedef enum
{
    OCTEST_WITHIN           = 0x0,
    OCTEST_EQUAL_TO         = 0x1,
    OCTEST_GREATER_THAN     = 0x2,
    OCTEST_GREATER_OR_EQUAL = 0x2 + OCTEST_EQUAL_TO,
    OCTEST_SMALLER_THAN     = 0x4,
    OCTEST_SMALLER_OR_EQUAL = 0x4 + OCTEST_EQUAL_TO,
    OCTEST_NOT_EQUAL        = 0x0,
    OCTEST_UNKNOWN
} OCTEST_COMPARISON_E;

typedef enum
{
    OCTEST_MSG_NULL            = 0x0,
    OCTEST_MSG_FUNC_CALL       = 0x1,
    OCTEST_MSG_VARIABLE        = 0x2,
} OCTEST_MESSAGE_TYPE_E;

typedef enum
{
    OCTEST_FUC_RETURN_VOID     = 0x0,
    OCTEST_FUC_RETURN_VALUE   = 0x1,
    OCTEST_FUC_RETURN_STRING   = 0x2,
} OCTEST_FUC_RETURN_TYPE_E;

void OCTestExecuteFucWithReturn(void * actual, const char *filepath, const char *calledFuncName,
                                const OCTEST_UINT32 lineNumber, const OCTEST_DISPLAY_STYLE_T style, OCTEST_FUC_RETURN_TYPE_E return_type);
void OCTestExpectEqualNumber(const OCTEST_INT32 expected, const OCTEST_INT32 actual, const char *filepath,
                            const char *message, OCTEST_MESSAGE_TYPE_E msg_type, const OCTEST_UINT32 lineNumber, const OCTEST_DISPLAY_STYLE_T style);
void OCTestExpectGreaterOrLessOrEqualNumber(const OCTEST_INT32 threshold, const OCTEST_INT32 actual, const OCTEST_COMPARISON_E compare,
                                            const char *filepath, const char *message, OCTEST_MESSAGE_TYPE_E msg_type, 
                                            const OCTEST_UINT32 lineNumber, const OCTEST_DISPLAY_STYLE_T style);
void OCTestExpectNumbersWithin(const OCTEST_UINT32 delta, const OCTEST_INT32 expected, const OCTEST_INT32 actual, const char *filepath,
                                const char *message, OCTEST_MESSAGE_TYPE_E msg_type, const OCTEST_UINT32 lineNumber, const OCTEST_DISPLAY_STYLE_T style);
                                
void OCTestResetTestCnt(void);

void OCTestPrintTestCnt(void);                                
#endif